<template lang="jade">
div#app
  div.return-bar
    i.iconfont(@click="back()") &#xe668;
    个人设置
  div.uc-set-up.mini_top

    ul.clearfix
      //li.sp(v-link="{ path: '/protrait'}")
      li.sp
        label 头像
        span.protrait
            img(:src="info.avatar")

    ul.clearfix
      li
        label 手机号码
        span {{ info.tel }}
      // li(v-link="{ name: 'editpwd' }")
      //  label 修改登录密码
      //  span 
      //    i.iconfont &#xe60a;

    ul.clearfix
      li
        label 真实姓名
        span {{ info.name }}
      li
        label 华兴账户
        span {{ info.acno }}


    button.login-out(v-on:click="loginOut()") 退出登录

</template>

<script>
import '../../assets/sass/user/setting.scss'
import {Api_LoginOut} from '../../config/api'

export default {

  data () {
    return {
      info: {},
      personName:''
    }
  },


  methods: {
 
    loginOut: function (next) {
      this.$http({url: Api_LoginOut, method: 'GET'}).then(function (response) {
        sessionStorage.removeItem("login");
        //sessionStorage.removeItem("loan")
        this.$route.router.go('/')
      }, function (response) {
          console.log(response)
      });
    },
    switchAccount(){

      if( sessionStorage.getItem("loan") == 'true' )
        sessionStorage.setItem("loan", false)
      else
        sessionStorage.setItem("loan", true)

      //console.log(sessionStorage.getItem("loan"));
      this.$route.router.go('/user')
    },

    goSetUp: function (next) {
      this.$route.router.go('/protrait?avatar='+this.info.avatar)
      //this.$route.router.go('/user-setup');
    },

    back(){
      //this.$route.router.go('/auto-buy')
      window.history.back();
    }
  },
  route: {
    activate ( transition ) {
      /*if( sessionStorage.getItem("login")==null){
        this.$route.router.go('/login')
        return false;
      }*/

      this.info = {
        'name': transition.to.query.name,
        'tel': transition.to.query.tel,
        'acno': transition.to.query.acno,
        'avatar':transition.to.query.avatar
      }

      if(sessionStorage.getItem("loan"))
        this.personName = "投资人"
      else
        this.personName = "借款人"

      transition.next();
    }
  }
}
</script>